package org.springmvc.util;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;

import java.io.Serializable;

/**
 * 响应信息封装
 * @time 2015年12月15日
 */
public class MsgResponse implements Serializable {
	private static final long serialVersionUID = -4714259069678234112L;
	/** 业务状态:true:成功;false:失败 */
	private boolean success = false;
	/** 业务代码 */
	private String code;
	/** 响应内容 */
	private String message;
	/** 响应扩展数据 */
	private Object data;
	public MsgResponse() {}
	public MsgResponse(boolean success) {
		this.success = success;
	}
	public boolean isSuccess() {
		return success;
	}
	public MsgResponse setSuccess(boolean success) {
		this.success = success;
		return this;
	}
	public String getCode() {
		return code;
	}
	public MsgResponse setCode(String code) {
		this.code = code;
		return this;
	}
	public String getMessage() {
		return message;
	}
	public MsgResponse setMessage(String message) {
		this.message = message;
		return this;
	}
	public Object getData() {
		return data;
	}
	public MsgResponse setData(Object data) {
		this.data = data;
		return this;
	}
	@Override
	public String toString() {
		return JSON.toJSONString(this, SerializerFeature.WriteDateUseDateFormat);
	}
}
